<template>
  <div class="container" ref="cesiumContainer"></div>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import * as Cesium from 'cesium'

// 1.安装cesium
// 2、讲cesium目录下的Build/Cesium 的四个目录拷贝倒public

// 设置cesium默认视角
Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees(89.5, 20.4, 110.4, 61.2)

const cesiumContainer = ref(null)

onMounted(() => {
  const viewer = new Cesium.Viewer(cesiumContainer.value, {
    infoBox: false, // 关闭信息框
    geocoder: false, // 关闭搜索
    homeButton: false, // home按钮
    sceneModePicker: false, // 场景查看器的场景模式
    baseLayerPicker: false, // 图层选择器
    navigationHelpButton: false, // 帮助按钮
    animation: false, // 动画播放
    timeline: false, //时间轴
    fullscreenButton: false, // 全屏按
  })

  // 隐藏logo
  viewer.cesiumWidget.creditContainer.style.display = 'none'

  // 生成广州塔的位置113.3191, 23.109,
  // const position = Cesium.Cartesian3.fromDegrees(113.3191, 23.109, 2000)

  // https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json
  let kmlUrl = './Assets/gdpPerCapita2008.kmz'

  let kmlDataPromise = Cesium.KmlDataSource.load(kmlUrl, {})
  kmlDataPromise.then(data => {
    console.log(data)
    viewer.dataSources.add(data)
  })
})
</script>
